{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Shopping list\n", "\n", "Let´s build a bot to collect the shopping list of a user in a dictionary. Use the input function to get the name of the user, and the names and number of items that the user wants to add to the shopping list. The expected result is a dictionary like this:\n", "\n", "```python\n", "shopping_list = {\n", " 'user_name': 'Mark Grayson',\n", " 'shopping_list': [\n", " {'product_name': 'Tomatoes', 'items': 3},\n", " {'product_name': 'Chicken', 'items': 4},\n", " {'product_name': 'Rice', 'items': 2}\n", " ]}\n", "```\n", "\n", "That is, we store the name of the user in a string field, and shopping list in a list of dictionaries where each dictionary has a 'product_name' key with the value of the name of the product and an 'items' key with the number of items to purchase.\n", "Once you have collected this information, can you count the total number of items to purchase?\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.4" } }, "nbformat": 4, "nbformat_minor": 4 }